$(function () {
    new Vue({
        el:'#header-avatar',
        data:{
            staff:''
        },
        components: {
            'avatar': Avatar.Avatar
        },
        created() {
            this.$http.get('report/initEndReportRecords').then(function (res) {
                console.log(res.body);
                let result = res.body.data;
                this.staff = result.staff.name;
            }, function () {
                console.log('请求失败！');
            });
        }
    });

    $.get('report/initEndReportRecords', function (data) {
        let department = data.data.department;
        let staff = data.data.staff;
        let abnormalCount = data.data.abnormalCount;
        $('#department-name').text(department.deptName+'后台管理');
        /*实例化多个Vue实例，缩小vue的作用范围，解决Vue和JQuery并存时点击事件失效*/
        new Vue({
            el:"#app",
            data:{
                department:department,
                staff:staff.name,
                abnormalCount:abnormalCount,
                unfinished:{
                    width: '30%'
                }
            },
            methods:{
                toReportRecordPage(grade) {
                    if (this.staff == grade.staff.name) {
                        window.location.href = 'backReportRecord.action';
                    } else {
                        return 0;
                    }
                }
            }
        });
    });
    $('.logout').click(function () {
       $.get('user/logout', function (data) {

       }) ;
       window.location.href = 'backLogin.action';
    });
});